Always save errno to a temporary before making other calls. (#335179,
authorMatthias Clasen <mclasen@redhat.com>
Mon, 20 Mar 2006 20:09:51 +0000 (20:09 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 20 Mar 2006 20:09:51 +0000 (20:09 +0000)
2006-03-20  Matthias Clasen  <mclasen@redhat.com>

        * gdk-pixbuf-animation.c:
        * gdk-pixbuf-io.c:
        * io-xpm.c:
        * io-xbm.c:
        * io-gif.c: Always save errno to a temporary before making
        other calls.  (#335179, Morten Welinder)

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-animation.c
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-xbm.c
gdk-pixbuf/io-xpm.c

index a6f602ed64372a28b2e4fbfa7bb9434663190955..1de3ab579a20746a8246502cb2f09aec4a4de9a6 100644 (file)
@@ -1,3 +1,12 @@
+2006-03-20  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk-pixbuf-animation.c: 
+       * gdk-pixbuf-io.c: 
+       * io-xpm.c: 
+       * io-xbm.c: 
+       * io-gif.c: Always save errno to a temporary before making
+       other calls.  (#335179, Morten Welinder)
+
 2006-03-14  Matthias Clasen  <mclasen@redhat.com>
 
        * io-gif.c (gdk_pixbuf__gif_image_load): Add a shortcut
index ad7e76fc9c85daa77be7ca86f89ca1f28b4cec32..e45bcfcd2b4676e8bd7142031acf10710267339c 100644 (file)
@@ -147,12 +147,13 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
         display_name = g_filename_display_name (filename);
        f = g_fopen (filename, "rb");
        if (!f) {
+                gint save_errno = errno;
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Failed to open file '%s': %s"),
                              display_name,
-                             g_strerror (errno));
+                             g_strerror (save_errno));
                 g_free (display_name);
                return NULL;
         }
index 52c30838a282027f5a1c76e1228883b78c51e619..a76f46431a6cef3f5fe47c56d930e518e87e66a1 100644 (file)
@@ -851,12 +851,13 @@ gdk_pixbuf_new_from_file (const char *filename,
 
        f = g_fopen (filename, "rb");
        if (!f) {
+               gint save_errno = errno;
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Failed to open file '%s': %s"),
                              display_name,
-                             g_strerror (errno));
+                             g_strerror (save_errno));
                 g_free (display_name);
                return NULL;
         }
@@ -1101,13 +1102,14 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
 
        f = g_fopen (filename, "rb");
        if (!f) {
+               gint save_errno = errno;
                 gchar *display_name = g_filename_display_name (filename);
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Failed to open file '%s': %s"),
                              display_name,
-                             g_strerror (errno));
+                             g_strerror (save_errno));
                 g_free (display_name);
                return NULL;
         }
@@ -1370,11 +1372,12 @@ save_to_file_callback (const gchar *buf,
 
        n = fwrite (buf, 1, count, filehandle);
        if (n != count) {
+               gint save_errno = errno;
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Error writing to image file: %s"),
-                             g_strerror (errno));
+                             g_strerror (save_errno));
                 return FALSE;
        }
        return TRUE;
@@ -1462,9 +1465,10 @@ save_to_callback_with_tmp_file (GdkPixbufModule   *image_module,
                goto end;
        f = fdopen (fd, "wb+");
        if (f == NULL) {
+               gint save_errno = errno;
                g_set_error (error,
                             G_FILE_ERROR,
-                            g_file_error_from_errno (errno),
+                            g_file_error_from_errno (save_errno),
                             _("Failed to open temporary file"));
                goto end;
        }
@@ -1487,9 +1491,10 @@ save_to_callback_with_tmp_file (GdkPixbufModule   *image_module,
                        break;
        }
        if (ferror (f)) {
+               gint save_errno = errno;
                g_set_error (error,
                             G_FILE_ERROR,
-                            g_file_error_from_errno (errno),
+                            g_file_error_from_errno (save_errno),
                             _("Failed to read from temporary file"));
                goto end;
        }
@@ -1720,13 +1725,14 @@ gdk_pixbuf_savev (GdkPixbuf  *pixbuf,
         f = g_fopen (filename, "wb");
         
         if (f == NULL) {
+               gint save_errno = errno;
                 gchar *display_name = g_filename_display_name (filename);
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Failed to open '%s' for writing: %s"),
                              display_name,
-                             g_strerror (errno));
+                             g_strerror (save_errno));
                 g_free (display_name);
                 return FALSE;
         }
@@ -1744,13 +1750,14 @@ gdk_pixbuf_savev (GdkPixbuf  *pixbuf,
        }
 
        if (fclose (f) < 0) {
+              gint save_errno = errno;
                gchar *display_name = g_filename_display_name (filename);
                g_set_error (error,
                             G_FILE_ERROR,
-                            g_file_error_from_errno (errno),
+                            g_file_error_from_errno (save_errno),
                             _("Failed to close '%s' while writing image, all data may not have been saved: %s"),
                             display_name,
-                            g_strerror (errno));
+                            g_strerror (save_errno));
                g_free (display_name);
                return FALSE;
        }
index 886ef9a59461f498d15ba3e97be11e646a1f724c..74fab8cc6e0958561172b8852749b43e1d4d6717 100644 (file)
@@ -214,11 +214,14 @@ gif_read (GifContext *context, guchar *buffer, size_t len)
 #endif
                retval = (fread(buffer, len, 1, context->file) != 0);
 
-                if (!retval && ferror (context->file))
+                if (!retval && ferror (context->file)) {
+                        gint save_errno = errno;
                         g_set_error (context->error,
                                      G_FILE_ERROR,
-                                     g_file_error_from_errno (errno),
-                                     _("Failure reading GIF: %s"), strerror (errno));
+                                     g_file_error_from_errno (save_errno),
+                                     _("Failure reading GIF: %s"), 
+                                     strerror (save_errno));
+                }
                 
 #ifdef IO_GIFDEBUG
                if (len < 100) {
index 90d8120a187ea801bda24aa2c532a0fb5bd74acf..5fe2cafdd0a3d3d83805f4d60c02dccc298c6de2 100644 (file)
@@ -435,10 +435,11 @@ gdk_pixbuf__xbm_image_load_increment (gpointer data,
        g_return_val_if_fail (data != NULL, FALSE);
 
        if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
+               gint save_errno = errno;
                context->all_okay = FALSE;
                 g_set_error (error,
                              G_FILE_ERROR,
-                             g_file_error_from_errno (errno),
+                             g_file_error_from_errno (save_errno),
                              _("Failed to write to temporary file when loading XBM image"));
                return FALSE;
        }
index 3357aab4b502969c95b943b67a716d521512e9d7..8959a04836a7b4ad1e60bbd2c25de832eeb95e91 100644 (file)
@@ -769,10 +769,11 @@ gdk_pixbuf__xpm_image_load_increment (gpointer data,
        g_return_val_if_fail (data != NULL, FALSE);
 
        if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
+              gint save_errno = errno;
                context->all_okay = FALSE;
                g_set_error (error,
                             G_FILE_ERROR,
-                            g_file_error_from_errno (errno),
+                            g_file_error_from_errno (save_errno),
                             _("Failed to write to temporary file when loading XPM image"));
                return FALSE;
        }